﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DTO;
using BUS;

namespace GUI
{
    public partial class frmChiTietPhieuNhapHang : DevComponents.DotNetBar.Metro.MetroForm
    {
        public frmChiTietPhieuNhapHang()
        {
            InitializeComponent();
        }

        private void frmChiTietPhieuNhapHang_Load(object sender, EventArgs e)
        {
            LoadChiTietPhieuNhapHang(frmMain.maphieunhap);
        }

        private void LoadChiTietPhieuNhapHang(int maphieunhap)
        {
            PhieuNhapHangBUS pnhbus = new PhieuNhapHangBUS();
            PhieuNhapHangDTO pnhdto = pnhbus.LayThongTinPhieuNhapHang(maphieunhap);
            ChiTietPhieuNhapHangBUS ctpnhbus = new ChiTietPhieuNhapHangBUS();
            ThietBiBUS tbbus = new ThietBiBUS();
            List<ChiTietPhieuNhapHangDTO> ds = ctpnhbus.LayDanhSachChiTietPhieuNhapTheoMaPhieuNhap(maphieunhap);
            for (int i = 0; i < ds.Count; i++)
            {
                dgvChiTietPhieuNhapHang.Rows.Add(i + 1, tbbus.LayThongTinThietBi(ds[i].MaThietBi).TenThietBi, ds[i].SoLuong, string.Format("{0:#,0.#}", ds[i].DonGia), string.Format("{0:#,0.#}", ds[i].ThanhTien));
            }
            txtTongTien.Text = string.Format("{0:#,0.#} VNĐ", pnhdto.TongTien);
            if(pnhdto.GhiChu != "")
                txtGhiChu.Text = pnhdto.GhiChu;
            else
                txtGhiChu.Text = "Ghi chú...";
        }
    }
}